const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')

module.exports = {
  mode: 'development',
  entry: './src/main-vue.js',
  output: {
    path: path.resolve(__dirname, '../dist'),
    filename: 'bundle.[contenthash].js',
    clean: true,
  },
  devServer: {
    static: {
      directory: path.join(__dirname, '../dist'),
    },
    open: true, // 直接打开
    port: 3000,
    hot: true,
    historyApiFallback: true,
  },
  module: {
    rules: [
      // { test: /\.css$/, use: ['style-loader', 'css-loader', ] },
      {
        test: /\.(scss|sass)$/,
        use: ['style-loader', 'css-loader', 'sass-loader'],
      },
      {
        test: /\.vue$/,
        use: ['vue-loader'],
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './public/index-vue.html',
      title: 'spa with vue',
    }),
    new VueLoaderPlugin(),
  ],
}
